using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace webapp4U.UI.Controls
{
    public partial class Title : System.Web.UI.UserControl
    {
        private int _AdvPosition;

        public int AdvPosition
        {
            get { return _AdvPosition; }
            set { _AdvPosition = value; }
        }
       

        protected void Page_Load(object sender, EventArgs e)
        {
            int CateID = -1;
            if (webapp4U.Globals.IsHomePage())
                CateID = Globals.ConvertToInt32(eAdvCategory.Trangchu);
            else
                CateID = Globals.ConvertToInt32(eAdvCategory.Trangcon);

            List<webapp4U.BOL.Advertise> list = webapp4U.BOL.Advertise.GetAdvertise(CateID, AdvPosition);
            rptAdvertise.DataSource = list;
            rptAdvertise.DataBind();
        }



        protected string GetAdvertise(string FileName, int Width, int Height)
        {
            if (System.IO.Path.GetExtension(FileName).ToLower() == ".swf")
                return "<script>WriteObject('" + Globals.ApplicationPath + "UserUpload/Logo/" + FileName + "' ," + Width + "," + Height + ");</script>";
            else
            {
                if (Width > 0 && Height > 0)
                    return "<img src='" + Globals.ApplicationPath + "UserUpload/Logo/" + FileName + "' border=0 width=" + Width + " Height=" + Height + "   />";
                else if (Width > 0)
                    return "<img src='" + Globals.ApplicationPath + "UserUpload/Logo/" + FileName + "' border=0 width=" + Width + " />";
                else if (Height > 0)
                    return "<img src='" + Globals.ApplicationPath + "UserUpload/Logo/" + FileName + "' border=0 Height=" + Height + " />";
                else
                    return "<img src='" + Globals.ApplicationPath + "UserUpload/Logo/" + FileName + "' border=0 />";
            }
        }

    }
}